﻿@using Board.Models
@{
    Layout = null;
}

@if (ViewBag.Unit != null)
{
    Unit unit = (Unit)(ViewBag.Unit);
    List<SelectListItem> bedStatusDropdown = new List<SelectListItem>();
    for (int i = 0; i < Bed.BedStatusList.Count; i++)
    {
        bedStatusDropdown.Add(new SelectListItem() { Text = Bed.BedStatusDescriptionList[i], Value = Bed.BedStatusList[i] });
    }
        if (unit.AccessibleBeds.Any())
        {
            <text>
                
                    <h6>@Html.ActionLink("Site " + unit.SiteId, "Unit", new{siteId=unit.SiteId}), @Html.ActionLink("Unit "+unit.UnitId, "Unit", new {siteId = unit.SiteId, unitId=unit.UnitId})</h6>
                    <div class="display-label">All beds: </div>
                    <div class="display-field">Status: @Html.DropDownList("UnitStatus"+unit.SiteId+"_"+unit.UnitId, bedStatusDropdown)  BedType:@Html.DropDownList("UnitBedType"+unit.SiteId+"_"+unit.UnitId, Bed.BedTypeList.Select(t => new SelectListItem() { Text = t, Value = t,  }), new { multiple = "multiple", @class = "multiple-select" }) <input type="button" value="Save", class="unit-save" id="UnitSave@(unit.SiteId + "_" + unit.UnitId)"/></div>
                    <div class="clear"></div>
                    @foreach (Bed bed in unit.AccessibleBeds.ToList().OrderBy(b => b.BedId))
                    {
                        <text>
                            <div class="bed-div status-@(bed.BedStatus)@(string.IsNullOrEmpty(bed.BedType)?"":" "+bed.BedType)">@Html.ActionLink(bed.BedId, "Unit", new{siteId = bed.SiteId, unitId = bed.UnitId, @bed = bed.BedId})</div>
                        </text>
                    }
<script> UpdateControls();
UpdateManagementControls();</script>
            </text>
        }
}
else if (ViewBag.Site != null)
{
    Site site = (Site) (ViewBag.Site);
    List<SelectListItem> bedStatusDropdown = new List<SelectListItem>();
    for (int i = 0; i < Bed.BedStatusList.Count; i++)
    {
        bedStatusDropdown.Add(new SelectListItem() { Text = Bed.BedStatusDescriptionList[i], Value = Bed.BedStatusList[i] });
    }
        <text>
                <h4>Site @site.SiteId</h4>
                <div class="display-label">All beds: </div>
                <div class="display-field">Status: @Html.DropDownList("SiteStatus"+site.SiteId, bedStatusDropdown)  BedType:@Html.DropDownList("SiteBedType"+site.SiteId, Bed.BedTypeList.Select(t => new SelectListItem() { Text = t, Value = t,  }), new { multiple = "multiple", @class = "multiple-select" }) <input type="button" value="Save", class="site-save" id="SiteSave@(site.SiteId)"/></div>
                @foreach (Unit unit in site.AccessibleUnit.ToList().OrderBy(u => u.UnitId))
                {
                    <text>
                        <div class="unit-div" id="UnitDiv@(unit.SiteId + "_" + unit.UnitId)">
                            <h6>@Html.ActionLink("Unit " + unit.UnitId, "Unit", new {siteId = unit.SiteId, unitId = unit.UnitId})</h6>
                            @foreach (Bed bed in unit.AccessibleBeds.ToList().OrderBy(b => b.BedId))
                            {
                                <text>
                                    <div class="bed-div status-@(bed.BedStatus)@(string.IsNullOrEmpty(bed.BedType)?"":" "+bed.BedType)">@Html.ActionLink(bed.BedId, "Unit", new {siteId = bed.SiteId, unitId = bed.UnitId, @bed = bed.BedId})</div>
                                </text>
                            }
                        </div>
                    </text>
                }
<script> UpdateControls();
    UpdateManagementControls();</script>
        </text>
}